// ECGViewOCX.cpp : Implementation of CECGViewOCXApp and DLL registration.

#include "stdafx.h"
#include "ECGViewOCX.h"
#include "..\ECGDraw.h"
#include "ECGDrawIf.h"
#include "..\ECGFile.h"
#include "..\..\Public\pubfun\IniReadWrite\IniReadWrite.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


CECGViewOCXApp NEAR theApp;

const GUID CDECL BASED_CODE _tlid =
		{ 0x39001339, 0x6e68, 0x4e02, { 0x87, 0xa, 0x9, 0xd4, 0x58, 0x7a, 0x54, 0x72 } };
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;


////////////////////////////////////////////////////////////////////////////
// CECGViewOCXApp::InitInstance - DLL initialization

BOOL CECGViewOCXApp::InitInstance()
{
	BOOL bInit = COleControlModule::InitInstance();

	if (bInit)
	{
		CECGDraw::Create();
		CECGDrawIf::Create();
		CECGFile::Create();
		CIniReadWrite::Create();
	}

	return bInit;
}


////////////////////////////////////////////////////////////////////////////
// CECGViewOCXApp::ExitInstance - DLL termination

int CECGViewOCXApp::ExitInstance()
{
	CECGDraw::Delete();
	CECGDrawIf::Delete();
	CECGFile::Delete();
	CIniReadWrite::Destroy();

	return COleControlModule::ExitInstance();
}


/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}


/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}
